package com.siss.tenancy.vo;

import com.github.pagehelper.Page;

import java.io.Serializable;
import java.util.List;

/**
 * 分页vo
 *
 * @author ygw
 * @create 2018-06-25 10:49
 */
public class PageResult<T> implements Serializable {

    /**
     * 封装分页对象，匹配前端UI需要的属性
     */
    private static final long serialVersionUID = 3287726360828330711L;

    private long total; // 总记录数
    private List<T> data; // 结果集
    private int code = 200;

    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public long getTotal() {
        return total;
    }

    public void setTotal(long total) {
        this.total = total;
    }

    public List<T> getData() {
        return data;
    }

    public void setData(List<T> data) {
        this.data = data;
    }

    public PageResult(List<T> list) {
        if (list instanceof Page) {
            Page<T> page = (Page<T>) list;
            this.total = page.getTotal();
            this.data = page;
        }
    }

}
